package com.rcoming.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.rcoming.R;
import com.rcoming.base.BaseActivity;
import com.rcoming.main.MainActivity;
import com.rcoming.main.MainApplication;
import com.rcoming.util.VersionUtil;

/**
 * 启动页
 *
 * @author Cazaea
 * @time 2017/5/9 9:01
 * @mail wistorm@sina.com
 */

public class SplashActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // 判断是否是第一次开启应用
        if (VersionUtil.getApkVersion(context) != MainApplication.getInstance().getSpUtil().getSavedVersionCode()) {
            Intent intent = new Intent(SplashActivity.this, GuideActivity.class);
            startActivity(intent);
            finish();
            return;
        }

        // 如果不是第一次启动app，则正常显示启动屏
        setContentView(R.layout.activity_splash);

        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                enterMainActivity();
            }
        }, 1500);

    }

    private void enterMainActivity() {

        startActivity(new Intent(SplashActivity.this, MainActivity.class));
        finish();

    }

}
